<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 定义一个30项的数组，数组的每一项要求都是**1~9之间的随机数**，每间隔5个数字，求出这五个数的平均值 -->
</body>
<script>
    var arr = [];
    for(i = 0 ; i < 30 ; i++){
        arr[i] = (Math.round( Math.random() * (9 - 1) + 1)); 
    }
    for(var j = 0 ; j < arr.length ; j +=5 ){
        var a = arr.slice(j,j + 5)
        console.log(average(a))
    }
    function average(a){
        var sum = 0;
        for(var i = 0 ; i < a.length ; i++){
            sum += a[i]
        }
        return sum/a.length
    }


</script>
</html>